package com.burges.net.dataStream.windows.windowAssigner

import org.apache.flink.api.java.utils.ParameterTool
import org.apache.flink.streaming.api.scala.{StreamExecutionEnvironment, _}

/**
  * Keyed和No-Keyed的区别
  */
object KeyedAndNonKeyedWindows {
  def main(args: Array[String]): Unit = {
    case class SensorEvent(id: Long, name: String, timestamp: Long)

    val parameterTool = ParameterTool.fromArgs(args)

    val env = StreamExecutionEnvironment.getExecutionEnvironment

    val sensorEvent = env.fromElements(SensorEvent(11, "Normal", 1L), SensorEvent(11, "Normal", 1L), SensorEvent(11, "Normal", 1L))

    //通过keyBy创建KeyedStream，然后调用window方法指定windowAssigner
//    sensorEvent.keyBy(event => event.id).window(new MyWindowsAssigner())
    //对于DataStream数据集，直接调用windowAll指定Windows Assigner
//    sensorEvent.windowAll(new MyAllWindowsAssigner())
  }

}
